var G_url="http://sl.deeyi.com/ydd/yddht_api/ci/index.php";
function URLencode(sStr){
	return escape(sStr).replace(/\+/g, '%2B').replace(/\"/g,'%22').replace(/\'/g, '%27').replace(/\//g,'%2F');
}

Date.prototype.format = function(format){
	var o = {
		"M+" : this.getMonth()+1, //month
		"d+" : this.getDate(), //day
		"h+" : this.getHours(), //hour
		"m+" : this.getMinutes(), //minute
		"s+" : this.getSeconds(), //cond
		"q+" : Math.floor((this.getMonth()+3)/3), //quarter
		"S" : this.getMilliseconds() //millisecond
	};
	if(/(y+)/.test(format)) {
		format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
	}

	for(var k in o) {
		if(new RegExp("("+ k +")").test(format)) {
			format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
		}
	}
	return format;
};


function resetcookie(){
	window.location.href="login.html";
	$.cookie('sign', null);
}

//表格导出
function expert_excel(){
	newtable=$(".datagrid-view2").find(".datagrid-btable").append('<table id="newtable">' +$("#table").html()+ '</table>');
	newtable.tableExport({
		type:'excel',
		separator:';',
		escape:'false'
	});
	$("#newtable").remove();
}
//判断小权限   p_sqx//login小权限名称
var g_layer_title;//修改的保存


function sqx(){

	// var str="新增,修改,保存";
	var n1=p_sqx.indexOf("新增");
	if(n1>=0){
		$('#xinzeng').attr("disabled",false);
		// $('#save_do').attr("disabled",false);
	}else if(n1<0){
		$('#xinzeng').attr("disabled",true);
	}

	var n2=p_sqx.indexOf("删除");
	if(n2>=0){
		$('#shanchu').attr("disabled",false);
	}else if(n2<0){
		$('#shanchu').attr("disabled",true);
	}


	if(p_sqx=="all"){
		$('#xinzeng').attr("disabled",false);
		$('#save_do').attr("disabled",false);
		$('#shanchu').attr("disabled",false);
	}

	if(p_sqx==""){
		$('#xinzeng').attr("disabled",true);
		$('#save_do').attr("disabled",true);
		$('#shanchu').attr("disabled",true);

	}


}


//保存权限
function sqx_save(a){
  var n3=p_sqx.indexOf("保存");
	if(n3>=0){
		$('#save_do').attr("disabled",false);
	}else if(n3<0){
		if(a=="新增"){
			$('#save_do').attr("disabled",false);
		}else{
			$('#save_do').attr("disabled",true);
		}
			// $('#save_do').attr("disabled",true);
	}

	if(p_sqx=="all"){
		$('#save_do').attr("disabled",false);
	}
}


//保存权限
function sqx_save_tcsz(a){
  var n3=p_sqx.indexOf("保存");
	if(n3>=0){
		$('#G_edit').attr("disabled",false);
	}else if(n3<0){
		if(a=="新增"){
			$('#G_edit').attr("disabled",false);
		}else{
			$('#G_edit').attr("disabled",true);
		}
			// $('#save_do').attr("disabled",true);
	}

	if(p_sqx=="all"){
		$('#G_edit').attr("disabled",false);
	}
}


//保存权限
function sqx_save_prsh(a){
  var n3=p_sqx.indexOf("保存");
	if(n3>=0){
		$('#save_dj').attr("disabled",false);
	}else if(n3<0){
		if(a=="新增"){
			$('#save_dj').attr("disabled",false);
		}else{
			$('#save_dj').attr("disabled",true);
		}
			// $('#save_do').attr("disabled",true);
	}

	if(p_sqx=="all"){
		$('#save_dj').attr("disabled",false);
	}
}



//排序功能
function banhao(){
	var len = $('#table tbody tr').length;
	for(var i = 0;i<len;i++){
		$('table tbody tr:eq('+i+') td:nth-child(2)').text(i+1);
	}
}

//排序功能
function banhao1(){
	var len = $('#table tbody tr').length;
	for(var i = 0;i<len;i++){
		$('table tbody tr:eq('+i+') td:nth-child(1)').text(i+1);
	}
}

//判断si的值修改显示内容
 function siFormatter(value, row) {
        if(value==1){
            return '入库';
        }else{
            return '出库';
        }
     }
